modified: openstmerge.py
[GalaxyCodeBases.git] / etc / whichpm / test / Option -a with a name finds duplicates
blob0471bd0cfbe58729ec9b7cc02c27d06ed614c08c
1 #!/usr/bin/env bash
3 # ---
4 # IMPORTANT: Use the following statement at the TOP OF EVERY TEST SCRIPT
5 # to ensure that this package's 'bin/' subfolder is added to the path so that
6 # this package's CLIs can be invoked by their mere filename in the rest
7 # of the script.
8 # ---
9 PATH=${PWD%%/test*}/bin:$PATH
11 # Helper function for error reporting.
12 die() { (( $# > 0 )) && echo "ERROR: $*" >&2; exit 1; }
14 # Look for duplicates, which, assuming that @INC contains '.', should
15 # find one, because of our dummy module in ./Data/Dumper.pm
16 out=$(whichpm -a -v Data::Dumper) || die
18 # Convert output lines to array.
19 IFS=$'\n' read -r -d '' -a lines <<<"$out"
21 # Make sure the corresponding paths are there.
22 pathFragment='/Data/Dumper.pm'
23 for (( i = 0; i < 2; i++ )); do
24 [[ ${lines[i]} =~ "$pathFragment"$ ]] || die "Expected '$pathFragment' in output line '${lines[i]}'."
25 done
27 # --- Make sure that the dummy module's version number was reported.
29 dummyVer='9.999'
30 [[ "${lines[1]}" =~ $'\t'"$dummyVer"$'\t' ]] || die "Expected '$dummyVer' in output line '${lines[1]}'."
32 # ---- Without -a, make sure that a warning notifying of the *existence* of a duplicate is reported.
34 errOut=$(whichpm Data::Dumper 2>&1 1>/dev/null) || die
36 grep -Fi 'duplicate' <<<"$errOut" || die "Expected duplicate warning in stderr output: '$errOut'."
38 exit 0